package com.nccsjz.back.leaveword.service;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.nccsjz.back.leaveword.dao.LeavewordDAO;
import com.nccsjz.base.BaseService;
import com.nccsjz.pojo.Leaveword;
import com.nccsjz.utils.Pager;

public class LeavewordService extends BaseService {

	public boolean addLv(Leaveword lv) throws SQLException {
		boolean f=false;
		this.openCon();
		f=new LeavewordDAO(con).addLeaveword(lv);
		this.closeCon();
		return f;
	}
/**
 * 
 * @param pageSize
 * @param pageNo
 * @param cas ,cas=1,为显示前台留言使用。即：已经审核通过的留言。
 * @return
 * @throws SQLException
 */
	public Pager getLvs(int pageSize, int pageNo,int cas) throws SQLException {
		Pager page;
		this.openCon();
		page=new LeavewordDAO(con).getLvs(pageSize, pageNo, cas);
		this.closeCon();
		return page;
	}
	
	public Leaveword getLeavewordById(long id) throws SQLException{
		Leaveword lv=null;
		this.openCon();
		lv=new LeavewordDAO(con).getLeaveword(id);
		this.closeCon();
		return lv;
	}
	/**
	 * 更新保存的留言
	 * @param lv
	 * @return
	 * @throws SQLException
	 */
	public boolean saveLv(Leaveword lv) throws SQLException {
		boolean f=false;
		this.openCon();
		f=new LeavewordDAO(con).saveLv(lv);
		this.closeCon();
		return f;
	}
	
	/**
	 * 删除ID留言
	 * @param id
	 * @return
	 * @throws SQLException
	 */
	public boolean deleteLvByID(Long id) throws SQLException{
		boolean f=false;
		this.openCon();
		f=new LeavewordDAO(con).deleteLeaveword(id);
		this.closeCon();
		return f;
	}
	public boolean delAll(long[] ids) throws SQLException {
		boolean f=false;
		this.openCon();
		f=new LeavewordDAO(con).delAll(ids);
		this.closeCon();
		return f;
	}

}
